package com.cloud.lawcase.api.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.cloud.lawcase.api.entity.TcRelPunishUnitLevel;
import com.cloud.lawcase.common.driver.SimpleInlangDriver;
import com.cloud.lawcase.common.utils.BaseMapperHelper;

public interface TcRelPunishUnitLevelMapper extends BaseMapperHelper<TcRelPunishUnitLevel> {

	@Delete("delete from tc_rel_punish_unit_level where cause_id = #{causeId}")
	void deleteByCauseId(long causeId);

	@Select("select t1.punish_id, t1.unit_func_level_id, t2.unit_func_level_name, t1.cause_id, t1.law_id from tc_rel_punish_unit_level t1, tc_dic_unit_func_level t2 where t1.unit_func_level_id = t2.unit_func_level_id and t1.law_id = #{lawId}")
	@Results({ @Result(column = "unit_func_level_id", property = "unitFuncLevelId", javaType = Integer.class),
			@Result(column = "unit_func_level_name", property = "unitFuncLevelName", javaType = String.class),
			@Result(column = "cause_id", property = "causeId", javaType = Long.class),
			@Result(column = "punish_id", property = "punishId", javaType = Long.class),
			@Result(column = "law_id", property = "lawId", javaType = Long.class) })
	List<TcRelPunishUnitLevel> listUnitLevelByLawId(long lawId);

	@Select("select t1.punish_id, t1.unit_func_level_id, t2.unit_func_level_name, t1.cause_id, t1.law_id from tc_rel_punish_unit_level t1, tc_dic_unit_func_level t2 where t1.unit_func_level_id = t2.unit_func_level_id and t1.cause_id in (#{causeIds})")
	@Lang(SimpleInlangDriver.class)
	@Results({ @Result(column = "unit_func_level_id", property = "unitFuncLevelId", javaType = Integer.class),
			@Result(column = "unit_func_level_name", property = "unitFuncLevelName", javaType = String.class),
			@Result(column = "cause_id", property = "causeId", javaType = Long.class),
			@Result(column = "punish_id", property = "punishId", javaType = Long.class),
			@Result(column = "law_id", property = "lawId", javaType = Long.class) })
	List<TcRelPunishUnitLevel> listUnitLevelByCauseIds(@Param("causeIds")List<Long> causeIds);
}